vraix=4201745.419-4201577.209
vraiy=189918.375-189859.856
vraiz=4778744.442-4779064.567

vrai=[vraix;vraiy;vraiz];

lonmin=-5.5
lonmax=10
latmin=41
latmax=52
paslon=1/10
paslat=1/10

data=load("gr3df97a.mnt");
data=reshape(data,4,length(data)/4);
x=data(1,:)';
y=data(2,:)';
z=data(3,:)';
sizelon=ceil((lonmax-lonmin)/paslon)+1;
sizelat=ceil((latmax-latmin)/paslat)+1;

x=flipud(reshape(x,sizelat,sizelon));
y=flipud(reshape(y,sizelat,sizelon));
z=flipud(reshape(z,sizelat,sizelon));
lat=48.84105487;
lon=2.58730777;

indlat=floor((latmax-lat)/paslat)+1;
indlon=floor((lon-lonmin)/paslon)+1;

dlon=lon-paslon*(indlon-1)-lonmin;
dlat=latmax-paslat*(indlat-1)-lat;

dx=x((indlat):(indlat+1),(indlon):(indlon+1))
dy=y((indlat):(indlat+1),(indlon):(indlon+1))
dz=z((indlat):(indlat+1),(indlon):(indlon+1))

a(:,:,1)=dx;
a(:,:,2)=dy;
a(:,:,3)=dz;

for i=1:3
data=a(:,:,i);
val1=(data(3)-data(1))/paslon*dlon+data(1);
val2=(data(4)-data(2))/paslon*dlon+data(2);
val=(val2-val1)/paslat*dlat+val1;
dd(i,1)=val;
end


